﻿using AutoMapper;

using BCVP.Net8.Common;
using BCVP.Net8.IService;
using BCVP.Net8.Model.Models;
using BCVP.Net8.Model.ViwModels;
using BCVP.Net8.Repository;
using BCVP.Net8.Repository.Base;

namespace BCVP.Net8.Service
{
    /// <summary>
    /// 服务接口实现
    /// </summary>
    public class AccessTrendLogService : BaseService<AccessTrendLog, AccessTrendLogViewModel>, IAccessTrendLogService
    {
        private readonly IBaseRepository<AccessTrendLog> _dal;
        private readonly IAccessTrendLogRepository _accessTrendLogRepository;
        private readonly IMapper _mapper;

        public AccessTrendLogService(IBaseRepository<AccessTrendLog> baseRepository, IMapper mapper, IAccessTrendLogRepository accessTrendLogRepository) : base(baseRepository, mapper)
        {
            _dal = baseRepository;
            _accessTrendLogRepository = accessTrendLogRepository;
            _mapper = mapper;
        }

        public async Task<AccessTrendLogViewModel> QueryByName(string name)
        {
            await Console.Out.WriteLineAsync($"Access_db context id : {base.Db.ContextID}");
            var entity = await _accessTrendLogRepository.QueryByName(name);
            var xx = entity.UserInfo.ObjToInt();
            return _mapper.Map<AccessTrendLogViewModel>(entity);
        }
    }
}
